package loginAndRegister;


import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {
    public static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        while (true) {
            System.out.println("请输入账号：6-20位字母、数字、下划线组成");
            String id = scan.next();
            Pattern p = Pattern.compile("^[a-zA-Z0-9_]{6,20}$");
            Matcher m = p.matcher(id);
            if (m.matches()) {
                System.out.println("输入正确");
                break;
            } else {
                System.out.println("请输入正确格式的账号");
            }
        }
        while (true) {
            System.out.println("请输入密码：包含大小写字母和数字的组合，不能使用特殊字符，长度不少于6位");
            String psw = scan.next();
            Pattern p1 = Pattern.compile("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,}$");
            Matcher m1 = p1.matcher(psw);
            if (m1.matches()) {
                System.out.println("请确认密码，再输入一遍");
                String psw1 = scan.next();
                if (psw.equals(psw1)) {
                    System.out.println("验证成功");
                    break;
                }
            } else {
                System.out.println("请输入正确格式的密码");
            }
        }
        while (true) {
            System.out.println("请输入邮箱");
            String email = scan.next();
            Pattern p2 = Pattern.compile("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$");
            Matcher m2 = p2.matcher(email);
            if (m2.matches()) {
                System.out.println("登陆成功，么么哒");
                break;
            } else {
                System.out.println("请输入正确格式的邮箱");
            }
        }
    }
}
